<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>


	<h:form id="srchForm">


		<p:selectOneRadio id="options" value="#{researchBean.selectedProd}"
			style="border: none">
			<f:selectItem itemLabel="Flight" itemValue="flight" />
			<f:selectItem itemLabel="Hotel" itemValue="hotel" />
			<f:selectItem itemLabel="Excursion" itemValue="excursion" />
			<p:ajax update="srchForm" />
		</p:selectOneRadio>

		<p:outputPanel id="researchFormVolo"
			rendered="#{researchBean.selectedProd == 'flight' }">

			<h5>When?</h5>
			<h:outputText value="starting date: " />
			<p:calendar value="#{researchBean.volo.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormVolo" />
			</p:calendar>

			<h:outputText value="ending date: " />
			<p:calendar value="#{researchBean.volo.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.volo.dataInizio}" />

			<h5>Where?</h5>
			<h:outputText value="departure city: " />
			<p:inputText id="departureCity"
				value="#{researchBean.volo.citta_partenza}" />

			<h:outputText value="arrival city: " />
			<p:inputText id="arrivalCity"
				value="#{researchBean.volo.citta_arrivo}" />
				
			<p:outputPanel id="mostraVoli">							

			<h:panelGrid id="displayVoli" columns="2" cellpadding="5">

				<p:dataTable var="voloDTO" value="#{researchBean.voloList}">
					<p:column headerText="company">
						<h:outputText value="#{voloDTO.compagnia}" />
					</p:column>

					<p:column headerText="departure date">
						<h:outputText value="#{voloDTO.dataInizio}" />
					</p:column>

					<p:column headerText="arrival date">
						<h:outputText value="#{voloDTO.dataFine}" />
					</p:column>

					<p:column headerText="departure city">
						<h:outputText value="#{voloDTO.citta_partenza}" />
					</p:column>

					<p:column headerText="arrival city">
						<h:outputText value="#{voloDTO.citta_arrivo}" />
					</p:column>
					
					<p:column headerText="Aggiungi">
						<h:commandButton value="Aggiungi a pacchetto" action="pacchettoBean.aggiungiProdottoBase( voloDTO )"/>
					</p:column>
				</p:dataTable>

			</h:panelGrid>
			
			<p:commandButton value="Search" update="mostraVoli"
				action="#{researchBean.searchVolo()}" style="margin-top: 20px" />
			
			</p:outputPanel>
			


		</p:outputPanel>

		<p:outputPanel id="researchFormHotel"
			rendered="#{researchBean.selectedProd == 'hotel' }">

			<h5>When?</h5>
			<h:outputText value="starting date: " />
			<p:calendar value="#{researchBean.hotel.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormHotel" />
			</p:calendar>

			<h:outputText value="ending date: " />
			<p:calendar value="#{researchBean.hotel.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.hotel.dataInizio}" />

			<h5>Where?</h5>
			<h:outputText value="city: " />
			<p:inputText value="#{researchBean.hotel.citta}" />
			
			<p:outputPanel id="mostraHotels">										

			<h:panelGrid id="displayHotels" columns="2" cellpadding="5">

				<p:dataTable var="hotelDTO" value="#{researchBean.hotelList}">
					<p:column headerText="company">
						<h:outputText value="#{hotelDTO.nome}" />
					</p:column>

					<p:column headerText="departure date">
						<h:outputText value="#{hotelDTO.dataInizio}" />
					</p:column>

					<p:column headerText="arrival date">
						<h:outputText value="#{hotelDTO.dataFine}" />
					</p:column>

					<p:column headerText="city">
						<h:outputText value="#{hotelDTO.citta}" />
					</p:column>
					
					<p:column headerText="Aggiungi">
						<h:commandButton value="Aggiungi a pacchetto" action="pacchettoBean.aggiungiProdottoBase( hotelDTO )"/>
					</p:column>

				</p:dataTable>

			</h:panelGrid>

			<p:commandButton value="Search" update="mostraHotels"
				action="#{researchBean.searchHotel()}" style="margin-top: 20px" />
				
			</p:outputPanel>

		</p:outputPanel>


		<p:outputPanel id="researchFormEscursione"
			rendered="#{researchBean.selectedProd == 'excursion' }">

			<h5>When?</h5>
			<h:outputText value="starting date: " />
			<p:calendar value="#{researchBean.escursione.dataInizio}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.today}">
				<p:ajax event="dateSelect" update="researchFormEscursione" />
			</p:calendar>
			
			<h:outputText value="ending date: " />
			<p:calendar value="#{researchBean.escursione.dataFine}"
				pattern="dd/MM/yyyy" mindate="#{researchBean.escursione.dataInizio}" />

			<h5>Where?</h5>
			<h:outputText value="city: " />
			<p:inputText value="#{researchBean.escursione.citta}" />
			
			<p:outputPanel id="mostraEscursioni">

			<h:panelGrid id="displayExcursions" columns="2" cellpadding="5">

				<p:dataTable var="escursioneDTO"
					value="#{researchBean.escursioneList}">


					<p:column headerText="date">
						<h:outputText value="#{escursioneDTO.dataInizio}" />
					</p:column>
					
					<p:column headerText="date">
						<h:outputText value="#{escursioneDTO.dataFine}" />
					</p:column>

					<p:column headerText="city">
						<h:outputText value="#{escursioneDTO.citta}" />
					</p:column>

					<p:column headerText="time">
						<h:outputText value="#{escursioneDTO.oraInizio}" />
					</p:column>
					
					<p:column headerText="Aggiungi">
						<h:commandButton value="Aggiungi a pacchetto" action="pacchettoBean.aggiungiProdottoBase( escursioneDTO )"/>
					</p:column>

				</p:dataTable>

			</h:panelGrid>
			

			<p:commandButton value="Search" update="mostraEscursioni"
				action="#{researchBean.searchEscursione()}" style="margin-top: 20px" />
				
			</p:outputPanel>

		</p:outputPanel>


	</h:form>

</body>
</html>